package com.xindz.cn.mvptest.shared.core.glide;

import android.content.Context;

import com.bumptech.glide.GlideBuilder;
import com.bumptech.glide.annotation.GlideModule;
import com.bumptech.glide.load.DecodeFormat;
import com.bumptech.glide.load.engine.cache.LruResourceCache;
import com.bumptech.glide.module.AppGlideModule;
import com.bumptech.glide.request.RequestOptions;
import com.xindz.cn.mvptest.R;
import com.xindz.cn.mvptest.app.AppConstant;

/**
 * @name Base
 * @class name：com.xindz.cn.base.shared.core.glide
 * @describe Glide使用配置 https://muyangmin.github.io/glide-docs-cn/doc/generatedapi.html
 * @anthor XINDZ
 * @time 2017/10/26 13:43
 * @change
 * @chang time
 * @class describe
 */
@GlideModule
public class MyAppGlideModule extends AppGlideModule {
    @Override
    public void applyOptions(Context context, GlideBuilder builder) {
        //设置内存缓存大小
        builder.setMemoryCache(new LruResourceCache(AppConstant.Catch.CATCH_SIZE_MEMORY));
//        builder.setDiskCache(new InternalCacheDiskCacheFactory(context,"磁盘缓存目录",AppConstant.Catch.CATCH_SIZE_DISK));
        builder.setDefaultRequestOptions(
                new RequestOptions()
                        .format(DecodeFormat.PREFER_ARGB_8888)//加载图片的质量
                        .placeholder(R.drawable.icon_placeholder)//占位符
                        .fallback(R.drawable.icon_empty)//空图片
                        .error(R.drawable.icon_error)
        );
    }

    @Override
    public boolean isManifestParsingEnabled() {
        //禁止清单解析,Glide低版本需要,4.+以上不需要
        return false;
    }

}
